package com.central.user.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.central.db.mapper.SuperMapper;
import com.central.common.model.SysUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 用户表 Mapper 接口
 *
 * @author td
 * @data 2018-10-29
 */
@Mapper
public interface SysUserMapper extends SuperMapper<SysUser> {
    /**
     * 分页查询所有用户列表
     * @param page
     * @param params
     * @return
     */
    List<SysUser> findUsers(Page<SysUser> page, @Param("u") Map<String, Object> params);

    /**
     * 分页查询当前项目所有用户列表
     * @param
     * @param page
     * @param params
     * @param userIds
     * @return
     */
    List<SysUser> findUsersByUserIds(Page<SysUser> page,@Param("u") Map<String, Object> params,@Param("list") Set<Long> userIds);

    List<SysUser> selectLikeUsername(@Param("u") Map<String, Object> params);

    @Update("UPDATE sys_user SET department_id = #{dapartmentId} WHERE id = #{id}")
    void updateDepartmentId(@Param("id") Long id,@Param("dapartmentId") Long departmentId);
    @Update("UPDATE sys_user SET nickname = #{nickname},mobile=#{mobile},email=#{email} WHERE id = #{id}")
    void updateUser(@Param("id")Long id,@Param("nickname") String nickname,@Param("mobile") String mobile,@Param("email") String email);
}
